#ifndef _SCENE_MANAGER_
#define _SCENE_MANAGER_

#include "..\Core\base.h"

#include "hge\hge.h"
#include "hge\hgeresource.h"
#include "hge\hgegui.h"

#include "..\Core\NetIO.h"
#include "..\Core\Acc.h"

namespace air {
	class Acc;

	struct Event;
	class IScene;
	class IGuiObject;
	class NetIO;

	class SceneManager {
	public:
		SceneManager();
		/**
		 * @brief destructor release current scene
		 */
		~SceneManager();
		/**
		 * @brief logic process function for current scene
		 *
		 * @param dt
		 *
		 * @return true for stop false for continue
		 */
		bool update(float dt);
		/**
		 * @brief render function for current scene
		 *m 
		 * @param dt
		 *
		 * @return true for stop false for continue
		 */
		bool render(float dt);
		/**	
		 * @brief start current Scne
		 */
		void start();

		bool initializeScene(IScene*);
		/**
		 * @brief set next scene to be shown. Scene 'next' will be initialized when 'current' end
		 */
		void setNextScene(IScene* _scene) { next = _scene; }

		void setHge(HGE* _hge)		{ hge = _hge; }
		void setGui(hgeGUI* _gui)	{ gui = _gui; }
		void setResourceManager(hgeResourceManager* _hgeResMan) { hgeResMan = _hgeResMan; }
		void setNetIO(NetIO* _netIO) { netIO = _netIO; }

		Acc* getAcc() { return &acc; }
		/**
		 * @brief add a GUIObject to hgeGui
		 *
		 * @param IGuiObject pointer to the GUIObject
		 *
		 * @return id assigned to this GUIObject
		 */
		int addGuiObject(IGuiObject*);
		/**
		 * @brief add a Object to scene
		 *
		 * @param obj pointer to the object
		 */
		void addObject(IObject* obj);
		/**
		 * @brief bind event with guiobject with the id equal to _id
		 *
		 * @param _id specify object
		 * @param pointer to Event Object
		 */
		void bindGuiObjectEvent(int _id, Event*);

	private:
		/**
		 * @brief current Scene being or to be displayed
		 */
		IScene* current;
		/**
		 * @brief next scene. next == NULL shows current scene is the last one.
		 */
		IScene* next;
		//Core*  core;
		/**
		 * @brief the id return from gui->update(float dt)
		 */
		int currentGuiId;
		/**
		 * @brief the last id assigned to GUI object
		 */
		int lastGuiId;
		NetIO *netIO;

		/**
		 * @brief map event from button' s id to Event object. support no more then 99 object.
		 */
		Event* eventMap[100];


		HGE* 				hge;
		hgeGUI* 			gui;
		hgeResourceManager* hgeResMan;

		Acc	acc;
	};
}
#endif
